package com.lbx.controller;

import com.lbx.util.CommonRes;
import com.lbx.util.ResUtil;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;

/**
 * @author lbx create by 2021/6/15 9:45
 * @apiNote MyController
 */
@RestController
@RequestMapping("/vue-element-admin")
@CrossOrigin
public class MyController {
    @RequestMapping("/transaction/list")
    public CommonRes<Object> list() {
        HashMap<String, Object> hashMap;
        ArrayList<HashMap<String, Object>> list = new ArrayList<>();
        for (int i = 0; i < 15; i++) {
            hashMap = new HashMap<>();
            hashMap.put("name", "刘岩" + i);
            hashMap.put("age", 18 + i);
            if (i % 2 > 0) {
                hashMap.put("sex", '女');
            } else {
                hashMap.put("sex", '男');
            }
            hashMap.put("status", "1");
            hashMap.put("create_time", new Date());
            list.add(hashMap);
        }
        HashMap<Object, Object> map = new HashMap<>();
        map.put("total", 15);
        map.put("items", list);
        return ResUtil.successRes(20000, "success", map);
    }
}
